package com.ptswitch.material.dao.impl;

import java.util.List;

import org.hxzon.project.SpringJdbcDao;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.ptswitch.material.model.material.BomMaterial;

@Repository
public class BomMaterialDao extends SpringJdbcDao {
    private static final RowMapper<BomMaterial> bomMaterialMapper = buildBeanRowMapper(BomMaterial.class);
    private static final String SelectCommon = "select id,bomId,code,designator,comment,footprint,value,voltage,quantity,stuffOpt,createTime,updateTime";
    private static final String FromTable = " from bomMaterial ";
    private static final String DefaultOrderBy = " order by code";

    public List<BomMaterial> findByBomId(String bomId) {
        String fullSql = SelectCommon + FromTable + " where bomId=:bomId" + DefaultOrderBy;
        return super.queryList(fullSql, buildMapParams("bomId", bomId), bomMaterialMapper);
    }

    public List<BomMaterial> findByMaterialCode(String code) {
        String fullSql = SelectCommon + FromTable + " where code=:code" + " order by createTime";
        return super.queryList(fullSql, buildMapParams("code", code), bomMaterialMapper);
    }

    public void saveAll(List<BomMaterial> bomMaterials) {

    }

    public void deleteAll() {

    }
}
